<?php

/**
 * Настройка блоков. Мы задаём как и где показывать наши блоки
 */
function openstore_config_blocks() {
  
    $blocks = array(	
   
   // Регион content_top	
    array('module' => 'views', 
	      'title' => 'Новости',
		  'delta' => 'news-block_2', 
		  'weight' => 1, 
		  'region' => 'content_top', 
		  'pages' => '<front>', 
		  'visibility' => 1,
		  'theme' => OPENSTORE_THEME,
		  'status' => 1,
		  ),
    array('module' => 'views', 
	      'title' => 'Рекомендованные товары',
		  'delta' => 'queues-block_1', 
		  'weight' => 2, 
		  'region' => 'content_top', 
		  'pages' => '<front>',
		  'visibility' => 1,
		  'theme' => OPENSTORE_THEME,
		  'status' => 1,
		  ),
    
	array('module' => 'views', 
	      'title' => 'Бестселлеры',
		  'delta' => 'popular_products-block_2', 
		  'weight' => 3, 
		  'region' => 'content_top', 
		  'pages' => '<front>',
		  'visibility' => 1,
		  'theme' => OPENSTORE_THEME,
		  'status' => 1,
		  ),
    array('module' => 'views',
          'title' => 'Лидеры рейтинга',	
	      'delta' => 'top_content-block_1', 
		  'weight' => 4, 
		  'region' => 'content_top', 
		  'pages' => '<front>',
		  'visibility' => 1,
		  'theme' => OPENSTORE_THEME,
		  'status' => 1,
		  ),
    array('module' => 'views', 
	      'title' => '<none>',
		  'delta' => 'conditional_blocks-block_7', 
		  'weight' => 5, 
		  'region' => 'content_top',
          'theme' => OPENSTORE_THEME,
          'status' => 1,		  
		  ),

    // Регион left    
	array('module' => 'uc_catalog',  // Каталог
	      'title' => 'Каталог',
		  'delta' => 0, 
		  'weight' => 1, 
		  'region' => 'left', 
		  'pages' => "<front>\r\ncatalog*", 
		  'visibility' => 1,
		  'theme' => OPENSTORE_THEME,
		  'status' => 1,
		  ),
    
	array('module' => 'views',
          'title' => 'Случайный товар',	
	      'delta' => 'uc_products-block_3', 
		  'weight' => 3, 
		  'region' => 'left', 
		  'pages' => '<front>',
		  'visibility' => 1,
		  'theme' => OPENSTORE_THEME,
		  'status' => 1,
		  ),
    array('module' => 'views', 
	      'title' => 'Популярные',
	      'delta' => 'conditional_blocks-block_4', 
		  'weight' => 4, 
		  'region' => 'left', 
		  'pages' => 'catalog/*',
		  'visibility' => 1,
		  'theme' => OPENSTORE_THEME,
		  'status' => 1,
		  ),
    array('module' => 'views',
	      'title' => 'Лидеры рейтинга',
	      'delta' => 'conditional_blocks-block_5', 
		  'weight' => 5, 
		  'region' => 'left', 
		  'pages' => 'catalog/*',
		  'visibility' => 1,
		  'theme' => OPENSTORE_THEME,
		  'status' => 1,
		  ),
		  
    array('module' => 'views', 
	      'title' => 'Скидки',
	      'delta' => 'conditional_blocks-block_2', 
		  'weight' => 6, 
		  'region' => 'left', 
		  'pages' => 'catalog/*',
		  'visibility' => 1,
		  'theme' => OPENSTORE_THEME,
		  'status' => 1,
		  ),
	array('module' => 'views', 
          'title' => 'Скидки',
	      'delta' => 'similar_products-block_3', 
		  'weight' => 7, 
		  'region' => 'left', 
		  'pages' => 'product/*',
		  'visibility' => 1,
		  'theme' => OPENSTORE_THEME,
		  'status' => 1,
		  ),
  
    // Регион right
	array('module' => 'uc_cart', 
	      'delta' => 0, 
		  'weight' => 1, 
		  'region' => 'right', 
		  'pages' => '<front>',
		  'visibility' => 1,
          'theme' => OPENSTORE_THEME,
          'status' => 1,		  
		  ),
		  
	array('module' => 'tagadelic', 
	      'title' => 'Производители',
		  'delta' => 3, // Дельта зависит от ID словаря. 3 - это словарь "Производители" 
		  'weight' => 2, 
		  'region' => 'right', 
		  'pages' => '<front>',
		  'visibility' => 1,
          'theme' => OPENSTORE_THEME,
          'status' => 1,		  
		  ),		  
		  		  
	array('module' => 'simplenews',
          'title' => 'Рассылки',	
	      'delta' => 1, // Дельта зависит от ID термина в словаре OPENSTORE_SIMPLENEWS_ID, который мы задали в taxonomy.inc
		  'weight' => 4, 
		  'region' => 'right', 
		  'pages' => "<front>\r\nproduct",
		  'visibility' => 1,
		  'theme' => OPENSTORE_THEME,
		  'status' => 1,
		  ),
	
/*
	array('module' => 'views',
          'subject' => 'Отзывы',	
	      'delta' => 'uc_products-block_1', 
		  'weight' => 6, 
		  'region' => 'right', 
		  'pages' => '<front>',
		  'visibility' => 1,
		  'theme' => OPENSTORE_THEME,
		  'status' => 1,
		  ),
*/		  
 	array('module' => 'views',
          'title' => 'Похожие товары',	
	      'delta' => 'similar_products-block_1', 
		  'weight' => 7, 
		  'region' => 'right', 
		  'pages' => 'product/*',
		  'visibility' => 1,
		  'theme' => OPENSTORE_THEME,
		  'status' => 1,
		  ), 
		 		  
    // Регион content_bottom		  		  
	array('module' => 'views',
          'title' => '<none>',	
	      'delta' => 'conditional_blocks-block_3', 
		  'weight' => 1, 
		  'region' => 'content_bottom', 
		  'pages' => 'catalog/*',
		  'visibility' => 1,
		  'theme' => OPENSTORE_THEME,
		  'status' => 1,
		  ),

	array('module' => 'views',	
	      'delta' => 'conditional_blocks-block_6', 
		  'weight' => 2, 
		  'region' => 'content_bottom',
          'theme' => OPENSTORE_THEME,
          'status' => 1,		  
		  ),

    // Регион product_collapsible
   /*	
	array('module' => 'views',
          'title' => 'Похожие товары',		
	      'delta' => 'conditional_blocks-block_1', 
		  'weight' => 1, 
		  'region' => 'product_collapsible', 
		  'pages' => 'node/*',
		  'visibility' => 1,
		  'theme' => OPENSTORE_THEME,
		  'status' => 1,
		  ),
    */
		  
    // Регион product_left_region		  
	array('module' => 'views',	
	      'title' => 'Похожие товары',
	      'delta' => 'similar_products-block_2', 
		  'weight' => 1, 
		  'region' => 'product_left_region', 
		  'pages' => 'node/*',
		  'visibility' => 1,
		  'theme' => OPENSTORE_THEME,
		  'status' => 1,
		  ),	  

	array('module' => 'views',	
	      'title' => 'C этим товаром также покупали',
	      'delta' => 'product_pairs_block-block_1', 
		  'weight' => 2, 
		  'region' => 'product_left_region', 
		  'pages' => 'node/*',
		  'visibility' => 1,
		  'theme' => OPENSTORE_THEME,
		  'status' => 1,
		  ),
		  
    array('module' => 'uc_recent_products',
          'title' => 'Последние просмотренные товары',	
	      'delta' => 0, 
		  'weight' => 3, 
		  'region' => 'product_left_region', 
		  'pages' => 'node/*',
		  'visibility' => 1,
          'theme' => OPENSTORE_THEME,
          'status' => 1,		  
		  ),		  

    // Регион profile_blocks
	array('module' => 'views',	
	      'title' => 'Мои закладки',
	      'delta' => 'flag_bookmarks-block_1', 
		  'weight' => 1, 
		  'region' => 'profile_blocks', 
		  'pages' => "<?php global \$user; if (arg(0) == 'user' && \$user->uid == arg(1) && is_numeric(arg(1)) && (arg(2) == NULL)) {return TRUE;} else {return FALSE;} ?>",
		  'visibility' => 2,
		  'custom' => 1,
		  'theme' => OPENSTORE_THEME,
		  'status' => 1,
		  ),
		  
	array('module' => 'views',	
	      'title' => 'Мои заказы',
	      'delta' => 'orders-block_2', 
		  'weight' => 2, 
		  'region' => 'profile_blocks', 
		  'pages' => "<?php global \$user; if (arg(0) == 'user' && \$user->uid == arg(1) && is_numeric(arg(1)) && (arg(2) == NULL)) {return TRUE;} else {return FALSE;} ?>",
		  'visibility' => 2,
		  'custom' => 1,
		  'theme' => OPENSTORE_THEME,
		  'status' => 1,
		  ),
		  
	array('module' => 'views',
          'title' => 'Моя корзина',	
	      'delta' => 'user_cart-block_1', 
		  'weight' => 3, 
		  'region' => 'profile_blocks', 
		  'pages' => "<?php global \$user; if (arg(0) == 'user' && \$user->uid == arg(1) && is_numeric(arg(1)) && (arg(2) == NULL)) {return TRUE;} else {return FALSE;} ?>",
		  'visibility' => 2,
		  'custom' => 1,
		  'theme' => OPENSTORE_THEME,
		  'status' => 1,
		  ),
		  
    // Регион wide_blocks
	array('module' => 'views',	
	      'title' => '<none>',
	      'delta' => 'queues-block_3', 
		  'weight' => -10, 
		  'region' => 'wide_blocks', 
		  'pages' => '<front>',
		  'visibility' => 1,
		  'theme' => OPENSTORE_THEME,
		  'status' => 1,
		  ),

	array('module' => 'views',	
	      'title' => '<none>',
	      'delta' => 'queues-block_2', 
		  'weight' => -9, 
		  'region' => 'wide_blocks', 
		  'pages' => '<front>',
		  'visibility' => 1,
		  'theme' => OPENSTORE_THEME,
		  'status' => 1,
		  ),

    // Регион primary_menu
	array('module' => 'megamenu',	
	      'title' => '<none>',
	      'delta' => 0, 
		  'weight' => -9, 
		  'region' => 'primary_menu', 
		  'pages' => '',
		  'visibility' => 0,
		  'theme' => OPENSTORE_THEME,
		  'status' => 1,
		  ),

    // Регион footer_block
    array('module' => 'menu',
          'title' => '<none>',
          'weight' => -9,		  
	      'delta' => 'menu-info', 
		  'region' => 'footer_block', 
		  'pages' => '',
		  'visibility' => 0,
		  'theme' => OPENSTORE_THEME,
		  'status' => 1,
		  ), 		  

    // Выключенные блоки
	array('module' => 'views',	
	      'title' => 'Последние поступления',
	      'delta' => 'new_products-block_1',  
		  'pages' => '<front>',
		  'visibility' => 1,
		  'status' => 0,
		  ),
		  
	array('module' => 'views',	
	      'title' => 'Последние заказы',
	      'delta' => 'uc_products-block_2',  
		  'pages' => '<front>',
		  'visibility' => 1,
		  'status' => 0,
		  ),

	array('module' => 'poll',	
	      'title' => 'Опросы',
	      'delta' => 0,  
		  'pages' => '<front>',
		  'visibility' => 1,
		  'status' => 0,
		  ),

	array('module' => 'views',	
	      'title' => 'Новости',
	      'delta' => 'news-block_1',  
		  'pages' => '<front>',
		  'visibility' => 1,
		  'status' => 0,
		  ),

	array('module' => 'menu',	
	      'title' => 'Каталог',
	      'delta' => 'menu-drop',  
		  'pages' => '<front>',
		  'visibility' => 1,
		  'status' => 0,
		  ),
	/*	  
    array('module' => 'views',	
	      'title' => 'Популярные товары',
		  'subject' => 'Популярные товары',
	      'delta' => 'popular-block_1',  
		  'pages' => '<front>',
		  'visibility' => 1,
		  'status' => 0,
		  ),
		  
	array('module' => 'views',	
	      'title' => 'Популярные товары',
		  'subject' => 'Популярные товары',
	      'delta' => 'popular-block',  
		  'pages' => '<front>',
		  'visibility' => 1,
		  'status' => 0,
		  ),		  
    */
	array('module' => 'views',	
	      'title' => 'Бестселлеры',
	      'delta' => 'popular_products-block_1',  
		  'pages' => '<front>',
		  'visibility' => 1,
		  'status' => 0,
		  ),		  

	array('module' => 'views',	
	      'title' => 'Последние отзывы',
	      'delta' => 'comments_recent-block_1',  
		  'pages' => '<front>',
		  'visibility' => 1,
		  'status' => 0,
		  ),

	array('module' => 'megamenu',	
	      'title' => 'Каталог',
	      'delta' => 0,  
		  'pages' => '<front>',
		  'visibility' => 1,
		  'status' => 0,
		  ),

	array('module' => 'superfish',	
	      'title' => '<none>',
	      'delta' => 1,   
		  'pages' => 'admin*',
		  'visibility' => 0,
		  'status' => 0,
		  ),
		  
	array('module' => 'menu',	
	      'title' => '<none>',
	      'delta' => 'primary-links',   
		  'pages' => 'admin*',
		  'visibility' => 0,
		  'status' => 0,
		  ),		  
		  
	array('module' => 'views',	
	      'title' => 'Опрос',
	      'delta' => 'poll-block_1',   
		  'pages' => '<front>',
		  'visibility' => 1,
		  'status' => 0,
		  ),

	array('module' => 'views',	
	      'title' => 'Акции',
	      'delta' => 'promotion-block_1',   
		  'pages' => 'admin*',
		  'visibility' => 0,
		  'status' => 0,
		  ),
	
	array('module' => 'general', 
	      'delta' => 1, 
		  'region' => 'right', 
		  'pages' => '<front>',
		  'visibility' => 1,
		  'status' => 0,
		  ),

	array('module' => 'general', 
	      'delta' => 0,  
		  'region' => 'right', 
		  'pages' => "<front>\r\ncontact",
		  'visibility' => 1,
		  'status' => 0,
		  ),

	array('module' => 'node',	
	      'delta' => 0,  
		  'region' => 'right', 
		  'pages' => '<front>',
		  'visibility' => 1,
		  'status' => 0,
		  ),

    array('module' => 'views',
          'title' => 'Скидки',	 
	      'delta' => 'discounts-block_1', 
		  'region' => 'left', 
		  'pages' => "product\r\n<front>\r\ncart",
		  'visibility' => 1,
		  'status' => 0,
		  ),   			  

    // Тема администратора
	
   // Регион dashboard_top
	array('module' => 'general',
          'title' => 'Состояние системы',	
	      'delta' => '5', 
		  'weight' => -10, 
		  'region' => 'dashboard_top', 
		  'pages' => 'admin',
		  'visibility' => 1,
		  'theme' => OPENSTORE_ADMIN_THEME,
		  'status' => 1,
		  ),

	array('module' => 'general',	
	      'delta' => '6', 
		  'weight' => -9, 
		  'region' => 'dashboard_top', 
		  'pages' => 'admin',
		  'visibility' => 1,
		  'theme' => OPENSTORE_ADMIN_THEME,
		  'status' => 1,
		  ),		  

	array('module' => 'views',	
	      'title' => 'Последние заказы',
	      'delta' => 'orders-block_1', 
		  'weight' => -8, 
		  'region' => 'dashboard_top', 
		  'pages' => 'admin',
		  'visibility' => 1,
		  'theme' => OPENSTORE_ADMIN_THEME,
		  'status' => 1,
		  ),
		  
	array('module' => 'views',	
	      'title' => 'Последние зарегистрированные',
	      'delta' => 'admin_users-block_1', 
		  'weight' => -7, 
		  'region' => 'dashboard_top', 
		  'pages' => 'admin',
		  'visibility' => 1,
		  'theme' => OPENSTORE_ADMIN_THEME,
		  'status' => 1,
		  ),

	array('module' => 'views',
          'title' => 'Последние отзывы',	
	      'delta' => 'comments_recent-block', 
		  'weight' => -6, 
		  'region' => 'dashboard_top', 
		  'pages' => 'admin',
		  'visibility' => 1,
		  'theme' => OPENSTORE_ADMIN_THEME,
		  'status' => 1,
		  ),

	array('module' => 'views',
          'title' => 'Последние рассылки',	
	      'delta' => 'newsletters-block_1', 
		  'weight' => -5, 
		  'region' => 'dashboard_top', 
		  'pages' => 'admin',
		  'visibility' => 1,
		  'theme' => OPENSTORE_ADMIN_THEME,
		  'status' => 1,
		  ),

	array('module' => 'views',
          'title' => 'Акции',	
	      'delta' => 'promotion-block_2', 
		  'weight' => -4, 
		  'region' => 'dashboard_top', 
		  'pages' => 'admin',
		  'visibility' => 1,
		  'theme' => OPENSTORE_ADMIN_THEME,
		  'status' => 1,
		  ), 		  
        );

    foreach ($blocks as $block) {
     drupal_write_record('blocks', $block); // Последовательно сохраняем в базе данных
   }
 }